package com.music.controller;

import com.music.pojo.Comment;
import com.music.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

@Controller
public class CommentController {
    @Autowired
    private CommentService commentService;

    @RequestMapping("/findAllComment")
    @ResponseBody
    public List<Comment> findAllComment(){
        List<Comment> list=commentService.findAllComment();
        return list;
    }

    @RequestMapping("/findInfoSongComment")
    @ResponseBody
    public List<Comment> findInfoSongComment(){
        int song_id=1;
        List<Comment> list=commentService.findInfoSongComment(song_id);
        return list;
    }

    @RequestMapping("/addComment")
    @ResponseBody
    public Map<Object,Object> addComment(){
        Map<Object,Object> result=new HashMap();
        Comment comment=new Comment();
        comment.setSong_id(2);
        comment.setUser_id(1);
        comment.setRemark("s1w166w6r1s");
        boolean flag=commentService.addComment(comment);
        if(flag) {
            result.put("status", "200");
            result.put("msg", "success");
        }
        return result;
    }

    @RequestMapping("/deleteComment")
    @ResponseBody
    public Map<Object,Object> deleteComment(){
        Map<Object,Object> result=new HashMap();
        int[] ids={1,2};
        boolean flag=commentService.deleteComment(ids);
        if (flag){
            result.put("status", "200");
            result.put("msg", "success");
        }
        return result;
    }
}
